import VXETable from 'vxe-table'
import PullDownTextarea from '../../../components/PullDownTextarea'
import { handlePropsMethod } from '../../../utils'

// 创建一个文本域渲染
VXETable.renderer.add('Textarea', {
  autofocus: '.el-input__inner',
  renderEdit(h, renderOpts, params) {
    const { $table } = params
    const { options = {} } = renderOpts
    const _options = handlePropsMethod(options, params, ['disabled'])

    return [
      <PullDownTextarea
        params={params}
        onChange={() => {
          $table.updateStatus(params)
        }}
        renderOptions={renderOpts}
        options={_options}
      />
    ]
  },
  renderCell(h, renderOpts, params) {
    const { row, column } = params
    const cellValue = row[column.property]

    return [<span>{cellValue}</span>]
  }
})

/** @type { Column } */
export const options = {
  showOverflow: 'tooltip',
  align: 'left'
}
